import java.util.Scanner;

/**
 * @author gao
 * @date 2025/9/21 19:11
 */

public class Solution {
    public int findSubstringInWraproundString(String s) {
        int n = s.length();
        int[] dp = new int[n];
        for (int i = 0; i < n; i++) {
            dp[i] = 1;
        }
        for (int i = 1; i < n; i++) {
            // 判断当前字符串是否与前一个相邻
            if (s.charAt(i - 1) + 1 == s.charAt(i) || (s.charAt(i - 1) == 'z' && s.charAt(i) == 'a')) {
                // 如果相邻，则当前字符串的长度加1
                dp[i] += dp[i - 1];
            }
        }
        char[] arr = s.toCharArray();
        int[] hash = new int[26];
        int ret = 0;
        // dp[i]表示以第i个字符结尾的字符串的最大长度
        for (int i = 0; i < n; i++) {
            hash[arr[i] - 'a'] = Math.max(hash[arr[i] - 'a'], dp[i]);
        }

        for (int i : hash) {
            ret += i;
        }
        return ret;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            String s = in.nextLine();
            Solution solution = new Solution();
            System.out.println(solution.findSubstringInWraproundString(s));
        }
    }
}